/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.recycling.web.controller;


import com.medusa.gruul.common.core.annotation.EscapeLogin;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.recycling.model.dto.CouponModifyDto;
import com.medusa.gruul.recycling.model.dto.FundModifyDto;
import com.medusa.gruul.recycling.model.dto.PopupWindowDto;
import com.medusa.gruul.recycling.model.vo.RecyclingSettingVo;
import com.medusa.gruul.recycling.service.IRecyclingSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 回收设置表 前端控制器
 * </p>
 *
 * @author whh
 * @since 2021-04-28
 */
@RestController
@Api(tags = "PC端-相关接口")
@RequestMapping("/recycling-setting")
public class RecyclingSettingController {

    @Autowired
    private IRecyclingSettingService recyclingSettingService;


    @GetMapping("info")
    @EscapeLogin
    @ApiOperation(value = "获取当前店铺回收相关配置查询", tags = "小程序端与pc端共用接口")
    public Result<RecyclingSettingVo> fundInfo() {
        RecyclingSettingVo vos = recyclingSettingService.getByTenantIdSetting();
        return Result.ok(vos);
    }

    @PutMapping("fund/modify")
    @ApiOperation(value = "商品基金设置修改")
    public Result fundModify(@RequestBody @Validated FundModifyDto settingDto) {
        recyclingSettingService.fundModify(settingDto);
        return Result.ok();
    }

    @PutMapping("coupon/modify")
    @ApiOperation(value = "回收卡券设置修改")
    public Result couponModify(@RequestBody @Validated CouponModifyDto couponModifyDto) {
        recyclingSettingService.couponModify(couponModifyDto);
        return Result.ok();
    }

    @PutMapping("popup/window")
    @ApiOperation(value = "弹窗设置")
    public Result popupWindow(@RequestBody @Validated PopupWindowDto popupWindowDto) {
        recyclingSettingService.popupWindow(popupWindowDto);
        return Result.ok();
    }
}
